package com.github.jettyrun.springinterface.demo.factorybean;

import com.github.jettyrun.springinterface.demo.bean.Car;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by jetty on 18/1/31.
 */
public class Main {

    public static void main(String[] args) {
        ApplicationContext beans=new ClassPathXmlApplicationContext("classpath:application-usertag.xml");
        Car protoTypeCar1= (Car)beans.getBean("protoTypeCarFactoryBean");
        Car protoTypeCar2= (Car)beans.getBean("protoTypeCarFactoryBean");
        System.out.println(""+(protoTypeCar1==protoTypeCar2)+" "+protoTypeCar1+" "+protoTypeCar2);
        Car singletonCar1= (Car)beans.getBean("singletonCarFactoryBean");
        Car singletonCar2= (Car)beans.getBean("singletonCarFactoryBean");
        System.out.println(""+(singletonCar1==singletonCar2)+" "+singletonCar1+" "+singletonCar2);

        SingletonCarFactoryBean factoryBean1=(SingletonCarFactoryBean)beans.getBean("&singletonCarFactoryBean");
        SingletonCarFactoryBean factoryBean2=(SingletonCarFactoryBean)beans.getBean("&singletonCarFactoryBean");
        System.out.println(""+(factoryBean1==factoryBean2)+" "+factoryBean1+" "+factoryBean2);

    }
}
